Skip to content

Comments

chore: snapshot and restore points for ai changes#2689

Merged
abose merged 11 commits intomainfrom
z
Feb 21, 2026
Merged

chore: snapshot and restore points for ai changes#2689
abose merged 11 commits intomainfrom
z

Conversation

@abose
Copy link
Member

@abose abose commented Feb 20, 2026

No description provided.

abose added 10 commits February 21, 2026 13:46
Move AISnapshotStore content from unbounded in-memory _contentStore to
disk-backed storage under <appSupportDir>/instanceData/<instanceId>/aiSnap/.
Content stays in _memoryBuffer during an AI turn and flushes to disk at
finalizeResponse() time. Reads check memory first, then fall back to disk.

Add per-instance heartbeat (60s interval) and garbage collection that
removes stale instance directories (>20 min without heartbeat) on startup.
Add integration tests covering snapshot data consistency: content-
addressable dedup, snapshot building/back-fill, multi-response
restore, file creation/deletion flows, and reset behavior. Expose
AISnapshotStore via brackets.test for test window access.
Store raw content in _readFiles instead of eagerly hashing on every
recordFileRead call. Content is only hashed when promoted to a snapshot
(on FS delete/rename), saving CPU and memory for the common read-only case.

Also fixes three resilience issues:
- _readContent: use hasOwnProperty for _memoryBuffer lookup so empty
  string content is not missed by the falsy check
- _closeAndDeleteFile: treat "file already gone" as success instead of
  rejecting, so restores don't report spurious errors
- _createOrUpdateFile: await CMD_OPEN completion before resolving to
  prevent race conditions with subsequent restore operations
Extract ~42 hardcoded English strings from AIChatPanel.js into
src/nls/root/strings.js using AI_CHAT_* keys. Replace all in-code
literals with Strings.* constants and StringUtils.format() for
parameterized text.

Fix a locale-sensitive bug where the Undo button click handler
compared $(this).text() against English "Undo" — now uses
data-action attributes instead.

Pass brackets.getLocale() to the Claude agent so non-English users
get responses in their display language.

Add i18n guidance section to CLAUDE.md.
When a tool (e.g. Write) streams slowly, the "receiving N bytes..."
preview would freeze. After 2s of no updates, rotate through
"Working...", "Writing...", "Processing..." every 3s so the user
sees the operation is still in progress. Timers are cleaned up
when tool info arrives.
Fix race condition in expectFileDeleted test helper where fileExists()
was fired on every awaitsFor poll but the result was checked before the
promise resolved, causing one-poll-behind behavior and timeouts.

Make _createOrUpdateFile resilient to stale FileSystem cache: when
file.exists() returns true but getDocumentForPath fails (e.g. after a
delete+recreate cycle), fall back to creating the file on disk and retry.
Two root causes identified and fixed:

1. expectFileDeleted used file.exists() which checks the _stat cache.
   After unlink, _handleDirectoryChange re-reads the parent dir and
   can repopulate _stat on the deleted File object from a racing
   readdir. Switch to FileSystem.existsAsync() which bypasses the
   cached _stat and goes directly to the impl.

2. _createOrUpdateFile could fail with NotFound when file.exists()
   returned stale true after a delete+recreate cycle. Add fallback:
   if getDocumentForPath fails, create the file on disk and retry.
Add getEditorState and takeScreenshot as MCP tools available to the
Claude Code SDK during AI chat queries. This gives Claude awareness of
which file the user is editing, their working set, live preview file,
and the ability to capture screenshots of the editor.

- Create src-node/mcp-editor-tools.js with tool definitions using the
  SDK's createSdkMcpServer/tool helpers
- Wire MCP server into claude-code-agent.js queryOptions
- Extract NodeConnector handlers into src/core-ai/aiPhoenixConnectors.js
  (getEditorState, takeScreenshot, getFileContent, applyEditToBuffer)
- Add Document.posFromIndex() to support position conversion without a
  master editor attached
- Add unit tests for Document.posFromIndex
@abose abose changed the title chore: snapshot andd restore points for ai changes chore: snapshot and restore points for ai changes Feb 21, 2026
Add expectCharAtIndex helper that checks both the returned position
and the actual character at that position, making the tests more
robust against regressions.
@sonarqubecloud
Copy link

@abose abose merged commit b303c98 into main Feb 21, 2026
19 of 21 checks passed
@abose abose deleted the z branch February 21, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant